package Demo;

public class Test  {
    String name="Admin";
    String password="123456";
    public void login(String name,String password) throws UserNameException,UserPasswordException
    {
        if(!this.name.equals(name))
        {
            System.out.println("用户名错误！");
            throw new UserNameException("你的用户名错了！！！");
        }
        if(!this.password.equals(password))
        {
            System.out.println("用户密码错误！");
            throw new UserPasswordException("你的密码错了！！！");
        }
    }
    public static void main(String[] args) {
        Test test=new Test();
        try
        {
            test.login("Admin","12345");
        }catch(UserNameException e)
        {
            e.printStackTrace();
            System.out.println("用户名异常！");
        }catch(UserPasswordException e)
        {
            e.printStackTrace();
            System.out.println("用户密码异常！");
        }finally
        {
            System.out.println("用户异常！！！！");
        }


    }
}
